package net.simflow.swf.analyzer.stringtrans;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.TreeSet;

import net.simflow.swf.analyzer.data.StringConstant;
import net.simflow.swf.analyzer.data.TupleStrInt;
import net.simflow.swf.analyzer.exec.data.ServiceOverAbilityRecord;
import net.simflow.swf.analyzer.exec.data.TaskExecResult;
import net.simflow.swf.analyzer.exec.stats.data.ExecStats;
import net.simflow.swf.analyzer.exec.stats.data.FlowExecTime;
import net.simflow.swf.analyzer.exec.stats.data.ServiceWaitTime;
import net.simflow.swf.analyzer.network.data.Flow;
import net.simflow.swf.analyzer.network.data.Service;

public class ExecStatsStringGenerator {
	private static final int MAX_LENGTH = 10;

	private static ExecStatsStringGenerator instance = new ExecStatsStringGenerator();

	private ExecStatsStringGenerator() {
	}

	public static ExecStatsStringGenerator getInstance() {
		return instance;
	}

	public ArrayList<TupleStrInt> generate(String style, ExecStats estats) {
		switch (style) {
		case ExecStats.EXECUTION_TIME_DISTRIBUTION:
			return this.getExecTimeDistributionString(estats);
		case ExecStats.FLOW_TOTAL_COUNT:
			return this.getFlowCountMapString(style,
					estats.getFlowTotalCountMap());
		case ExecStats.FLOW_EXECUTED_COUNT:
			return this.getFlowCountMapString(style,
					estats.getFlowExecCountMap());
		case ExecStats.FLOW_UNFINISHED_COUNT:
			return this.getFlowCountMapString(style,
					estats.getFlowUnfinishedCountMap());
		case ExecStats.FLOW_TOTAL_COUNT_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowTotalCountDistribution());
		case ExecStats.FLOW_EXECUTED_COUNT_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowExecCountDistribution());
		case ExecStats.FLOW_UNFINISHED_COUNT_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowUnfinishedCountDistribution());
		case ExecStats.FLOW_OVER_ABILITY_TIME:
			return this.getFlowOverAbilityMapString(style,
					estats.getFlowOverAbilityTimeMap());
		case ExecStats.FLOW_OVER_ABILITY_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowOverAbilityTimeDistribution());
		case ExecStats.SERVICE_TOTAL_COUNT:
			return this.getServiceCountMapString(style,
					estats.getServiceTotalCountMap());
		case ExecStats.SERVICE_EXECUTED_COUNT:
			return this.getServiceCountMapString(style,
					estats.getServiceExecCountMap());
		case ExecStats.SERVICE_UNFINISHED_COUNT:
			return this.getServiceCountMapString(style,
					estats.getServiceUnfinishedCountMap());
		case ExecStats.SERVICE_TOTAL_COUNT_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceTotalCountDistribution());
		case ExecStats.SERVICE_EXECUTED_COUNT_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceExecCountDistribution());
		case ExecStats.SERVICE_UNFINISHED_COUNT_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceUnfinishedCountDistribution());
		case ExecStats.SERVICE_WAIT_TIME:
			return this.getServiceWaitTimeMapString(style,
					estats.getServiceWaitTimeMap());
		case ExecStats.SERVICE_MAX_WAIT_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceMaxWaitTimeDistribution());
		case ExecStats.SERVICE_MIN_WAIT_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceMinWaitTimeDistribution());
		case ExecStats.SERVICE_AVG_WAIT_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceAvgWaitTimeDistribution());
		case ExecStats.SERVICE_OVER_ABILITY_TIME:
			return this.getServiceCountMapString(style,
					estats.getServiceOverAbilityTimeMap());
		case ExecStats.SERVICE_OVER_ABILITY_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceOverAbilityTimeDistribution());
		case ExecStats.FLOW_EXEC_TIME:
			return this.getFlowExecTimeMapString(style,
					estats.getFlowExecTimeMap());
		case ExecStats.FLOW_MAX_EXEC_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowMaxExecTimeDistribution());
		case ExecStats.FLOW_MIN_EXEC_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowMinExecTimeDistribution());
		case ExecStats.FLOW_AVG_EXEC_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowAvgExecTimeDistribution());
		}
		return null;
	}

	public ArrayList<TupleStrInt> generate(String style, ExecStats estats,
			Flow flow) {
		switch (style) {
		case ExecStats.EXECUTION_TIME_DISTRIBUTION:
			return this.getExecTimeDistributionString(estats, flow);
		case ExecStats.FLOW_TOTAL_COUNT:
			return this.getFlowCountMapString(style,
					estats.getFlowTotalCountMap(), flow);
		case ExecStats.FLOW_EXECUTED_COUNT:
			return this.getFlowCountMapString(style,
					estats.getFlowExecCountMap(), flow);
		case ExecStats.FLOW_UNFINISHED_COUNT:
			return this.getFlowCountMapString(style,
					estats.getFlowUnfinishedCountMap(), flow);
		case ExecStats.FLOW_TOTAL_COUNT_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowTotalCountDistribution(), flow);
		case ExecStats.FLOW_EXECUTED_COUNT_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowExecCountDistribution(), flow);
		case ExecStats.FLOW_UNFINISHED_COUNT_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowUnfinishedCountDistribution(), flow);
		case ExecStats.FLOW_OVER_ABILITY_TIME:
			return this.getFlowOverAbilityMapString(style,
					estats.getFlowOverAbilityTimeMap(), flow);
		case ExecStats.FLOW_OVER_ABILITY_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowOverAbilityTimeDistribution(), flow);
		case ExecStats.SERVICE_TOTAL_COUNT:
			return this.getServiceCountMapString(style,
					estats.getServiceTotalCountMap(), flow);
		case ExecStats.SERVICE_EXECUTED_COUNT:
			return this.getServiceCountMapString(style,
					estats.getServiceExecCountMap(), flow);
		case ExecStats.SERVICE_UNFINISHED_COUNT:
			return this.getServiceCountMapString(style,
					estats.getServiceUnfinishedCountMap(), flow);
		case ExecStats.SERVICE_TOTAL_COUNT_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceTotalCountDistribution(), flow);
		case ExecStats.SERVICE_EXECUTED_COUNT_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceExecCountDistribution(), flow);
		case ExecStats.SERVICE_UNFINISHED_COUNT_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceUnfinishedCountDistribution(), flow);
		case ExecStats.SERVICE_WAIT_TIME:
			return this.getServiceWaitTimeMapString(style,
					estats.getServiceWaitTimeMap(), flow);
		case ExecStats.SERVICE_MAX_WAIT_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceMaxWaitTimeDistribution(), flow);
		case ExecStats.SERVICE_MIN_WAIT_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceMinWaitTimeDistribution(), flow);
		case ExecStats.SERVICE_AVG_WAIT_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceAvgWaitTimeDistribution(), flow);
		case ExecStats.SERVICE_OVER_ABILITY_TIME:
			return this.getServiceCountMapString(style,
					estats.getServiceOverAbilityTimeMap(), flow);
		case ExecStats.SERVICE_OVER_ABILITY_TIME_DISTRIBUTION:
			return this.getServiceDistributionString(style,
					estats.getServiceOverAbilityTimeDistribution(), flow);
		case ExecStats.FLOW_EXEC_TIME:
			return this.getFlowExecTimeMapString(style,
					estats.getFlowExecTimeMap(), flow);
		case ExecStats.FLOW_MAX_EXEC_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowMaxExecTimeDistribution(), flow);
		case ExecStats.FLOW_MIN_EXEC_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowMinExecTimeDistribution(), flow);
		case ExecStats.FLOW_AVG_EXEC_TIME_DISTRIBUTION:
			return this.getFlowDistributionString(style,
					estats.getFlowAvgExecTimeDistribution(), flow);
		}
		return null;
	}

	private ArrayList<TupleStrInt> getExecTimeDistributionString(
			ExecStats estats) {
		if (estats.getExecTimeDistribution() == null) {
			return null;
		}
		estats.getExecTimeDistribution().comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<Integer, ArrayList<TaskExecResult>> en : estats
				.getExecTimeDistribution().descendingMap().entrySet()) {
			TreeSet<String> set = new TreeSet<String>();
			for (TaskExecResult r : en.getValue()) {
				set.add(r.getFlow().getNameInNetwork());
				if (set.size() >= MAX_LENGTH) {
					break;
				}
			}
			set.comparator();

			StringBuffer str = new StringBuffer();
			str.append(en.getKey());
			str.append(" (").append(en.getValue().size()).append(")")
					.append(":");
			for (String s : set) {
				str.append(" ").append(s).append(";");
			}
			if (set.size() >= MAX_LENGTH && en.getValue().size() > MAX_LENGTH) {
				str.append("...");
			}
			info.add(new TupleStrInt(str.toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(ExecStats.EXECUTION_TIME_DISTRIBUTION,
				StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getExecTimeDistributionString(
			ExecStats estats, Flow flow) {
		if (estats.getExecTimeDistribution() == null) {
			return null;
		}
		estats.getExecTimeDistribution().comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<Integer, ArrayList<TaskExecResult>> en : estats
				.getExecTimeDistribution().descendingMap().entrySet()) {
			int c = 0;
			TreeSet<String> set = new TreeSet<String>();
			for (TaskExecResult r : en.getValue()) {
				if (r.getFlow() == flow) {
					if (c < MAX_LENGTH) {
						set.add(r.getInfo());
					}
					c++;
				}
			}
			set.comparator();

			if (c != 0) {
				StringBuffer str = new StringBuffer();
				str.append(en.getKey());
				str.append(" (").append(c).append(")").append(":");
				for (String s : set) {
					str.append(" (").append(s).append(");");
				}
				if (c > MAX_LENGTH) {
					str.append("...");
				}
				info.add(new TupleStrInt(str.toString(), StringConstant.CONTENT));
			}
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(ExecStats.EXECUTION_TIME_DISTRIBUTION,
				StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getServiceCountMapString(String title,
			HashMap<Service, Integer> serviceCountMap) {
		if (serviceCountMap == null) {
			return null;
		}

		TreeMap<String, Integer> map = new TreeMap<String, Integer>();
		for (Entry<Service, Integer> en : serviceCountMap.entrySet()) {
			map.put(en.getKey().getNameInNetwork(), en.getValue());
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, Integer> en : map.entrySet()) {
			info.add(new TupleStrInt(en.getKey() + ": " + en.getValue(),
					StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}
		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getServiceCountMapString(String title,
			HashMap<Service, Integer> serviceCountMap, Flow flow) {
		if (serviceCountMap == null) {
			return null;
		}

		TreeMap<String, Integer> map = new TreeMap<String, Integer>();
		for (Service svc : flow.getServiceSet()) {
			Integer c = serviceCountMap.get(svc);
			if (c != null) {
				map.put(svc.getNameInNetwork(), c);
			}
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, Integer> en : map.entrySet()) {
			if (en.getValue() != null) {
				info.add(new TupleStrInt(en.getKey() + ": " + en.getValue(),
						StringConstant.CONTENT));
			}
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getServiceWaitTimeMapString(String title,
			HashMap<Service, ServiceWaitTime> serviceWaitTimeMap) {
		if (serviceWaitTimeMap == null) {
			return null;
		}

		TreeMap<String, ServiceWaitTime> map = new TreeMap<String, ServiceWaitTime>();
		for (Entry<Service, ServiceWaitTime> en : serviceWaitTimeMap.entrySet()) {
			map.put(en.getKey().getNameInNetwork(), en.getValue());
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, ServiceWaitTime> en : map.entrySet()) {
			info.add(new TupleStrInt(en.getKey() + ": "
					+ en.getValue().toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}
		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getServiceWaitTimeMapString(String title,
			HashMap<Service, ServiceWaitTime> serviceWaitTimeMap, Flow flow) {
		if (serviceWaitTimeMap == null) {
			return null;
		}

		TreeMap<String, ServiceWaitTime> map = new TreeMap<String, ServiceWaitTime>();
		for (Service svc : flow.getServiceSet()) {
			map.put(svc.getNameInNetwork(), serviceWaitTimeMap.get(svc));
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, ServiceWaitTime> en : map.entrySet()) {
			info.add(new TupleStrInt(en.getKey() + ": "
					+ en.getValue().toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getServiceDistributionString(String title,
			TreeMap<? extends Number, ArrayList<Service>> serviceDistribution) {
		if (serviceDistribution == null) {
			return null;
		}
		serviceDistribution.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<? extends Number, ArrayList<Service>> en : serviceDistribution
				.descendingMap().entrySet()) {
			TreeSet<String> set = new TreeSet<String>();
			for (Service svc : en.getValue()) {
				set.add(svc.getNameInNetwork());
				if (set.size() >= MAX_LENGTH) {
					break;
				}
			}
			set.comparator();

			StringBuffer str = new StringBuffer();
			str.append(en.getKey());
			str.append(" (").append(en.getValue().size()).append(")")
					.append(":");
			for (String s : set) {
				str.append(" ").append(s).append(";");
			}
			if (set.size() >= MAX_LENGTH && en.getValue().size() > MAX_LENGTH) {
				str.append("...");
			}

			info.add(new TupleStrInt(str.toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getServiceDistributionString(String title,
			TreeMap<? extends Number, ArrayList<Service>> serviceDistribution,
			Flow flow) {
		if (serviceDistribution == null) {
			return null;
		}
		serviceDistribution.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<? extends Number, ArrayList<Service>> en : serviceDistribution
				.descendingMap().entrySet()) {
			int c = 0;
			TreeSet<String> set = new TreeSet<String>();
			for (Service svc : en.getValue()) {
				if (flow.getServiceSet().contains(svc)) {
					if (c < MAX_LENGTH) {
						set.add(svc.getNameInNetwork());
					}
					c++;
				}
			}
			set.comparator();

			if (c != 0) {
				StringBuffer str = new StringBuffer();
				str.append(en.getKey());
				str.append(" (").append(c).append(")").append(":");
				for (String s : set) {
					str.append(" (").append(s).append(");");
				}
				if (c > MAX_LENGTH) {
					str.append("...");
				}
				info.add(new TupleStrInt(str.toString(), StringConstant.CONTENT));
			}
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowCountMapString(String title,
			HashMap<Flow, ArrayList<TaskExecResult>> flowCountMap) {
		if (flowCountMap == null) {
			return null;
		}

		TreeMap<String, Integer> map = new TreeMap<String, Integer>();
		for (Entry<Flow, ArrayList<TaskExecResult>> en : flowCountMap
				.entrySet()) {
			map.put(en.getKey().getNameInNetwork(), en.getValue().size());
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, Integer> en : map.entrySet()) {
			info.add(new TupleStrInt(en.getKey() + ": " + en.getValue(),
					StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}
		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowCountMapString(String title,
			HashMap<Flow, ArrayList<TaskExecResult>> flowCountMap, Flow flow) {
		if (flowCountMap == null) {
			return null;
		}

		ArrayList<TaskExecResult> a = flowCountMap.get(flow);
		int c;
		if (a == null) {
			c = 0;
		} else {
			c = a.size();
		}

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		info.add(new TupleStrInt(title, StringConstant.TITLE));
		info.add(new TupleStrInt(flow.getNameInNetwork() + ": " + c,
				StringConstant.CONTENT));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowDistributionString(String title,
			TreeMap<? extends Number, ArrayList<Flow>> flowDistribution) {
		if (flowDistribution == null) {
			return null;
		}
		flowDistribution.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<? extends Number, ArrayList<Flow>> en : flowDistribution
				.descendingMap().entrySet()) {
			TreeSet<String> set = new TreeSet<String>();
			for (Flow flow : en.getValue()) {
				set.add(flow.getNameInNetwork());
				if (set.size() >= MAX_LENGTH) {
					break;
				}
			}
			set.comparator();

			StringBuffer str = new StringBuffer();
			str.append(en.getKey());
			str.append(" (").append(en.getValue().size()).append(")")
					.append(":");
			for (String s : set) {
				str.append(" ").append(s).append(";");
			}
			if (set.size() >= MAX_LENGTH && en.getValue().size() > MAX_LENGTH) {
				str.append("...");
			}

			info.add(new TupleStrInt(str.toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowDistributionString(String title,
			TreeMap<? extends Number, ArrayList<Flow>> flowDistribution,
			Flow flow) {
		if (flowDistribution == null) {
			return null;
		}
		flowDistribution.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<? extends Number, ArrayList<Flow>> en : flowDistribution
				.descendingMap().entrySet()) {
			if (en.getValue().contains(flow)) {
				info.add(new TupleStrInt(en.getKey() + ": "
						+ flow.getNameInNetwork(), StringConstant.CONTENT));
			}
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowOverAbilityMapString(String title,
			HashMap<Flow, ServiceOverAbilityRecord> flowOverAbilityMap) {
		if (flowOverAbilityMap == null) {
			return null;
		}

		TreeMap<String, ServiceOverAbilityRecord> map = new TreeMap<String, ServiceOverAbilityRecord>();
		for (Entry<Flow, ServiceOverAbilityRecord> en : flowOverAbilityMap
				.entrySet()) {
			map.put(en.getKey().getNameInNetwork(), en.getValue());
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, ServiceOverAbilityRecord> en : map.entrySet()) {
			info.add(new TupleStrInt(en.getKey() + ": "
					+ en.getValue().toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}
		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowOverAbilityMapString(String title,
			HashMap<Flow, ServiceOverAbilityRecord> flowOverAbilityMap,
			Flow flow) {
		if (flowOverAbilityMap == null) {
			return null;
		}

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		ServiceOverAbilityRecord rec = flowOverAbilityMap.get(flow);
		if (rec != null) {
			info.add(new TupleStrInt(flow.getNameInNetwork() + ": "
					+ rec.getTime(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}

		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowExecTimeMapString(String title,
			HashMap<Flow, FlowExecTime> flowExecTimeMap) {
		if (flowExecTimeMap == null) {
			return null;
		}

		TreeMap<String, FlowExecTime> map = new TreeMap<String, FlowExecTime>();
		for (Entry<Flow, FlowExecTime> en : flowExecTimeMap.entrySet()) {
			map.put(en.getKey().getNameInNetwork(), en.getValue());
		}
		map.comparator();

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, FlowExecTime> en : map.entrySet()) {
			info.add(new TupleStrInt(en.getKey() + ": "
					+ en.getValue().toString(), StringConstant.CONTENT));
		}

		if (info.isEmpty()) {
			return null;
		}
		info.add(0, new TupleStrInt(title, StringConstant.TITLE));
		return info;
	}

	private ArrayList<TupleStrInt> getFlowExecTimeMapString(String title,
			HashMap<Flow, FlowExecTime> flowExecTimeMap, Flow flow) {
		if (flowExecTimeMap == null) {
			return null;
		}

		FlowExecTime res = flowExecTimeMap.get(flow);
		if (res == null) {
			return null;
		}

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		info.add(new TupleStrInt(title, StringConstant.TITLE));
		info.add(new TupleStrInt(flow.getNameInNetwork() + ": "
				+ res.toString(), StringConstant.CONTENT));
		return info;
	}
}
